package com.andy.qhb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;


@SpringBootApplication
//@EnableTransactionManagement
@EnableScheduling
public class QhbApplication {
	
	public static int ServerStatus = 0; // 0-启动中，1-启动完成，2-关闭中
	
	public static void main(String[] args) {
		SpringApplication.run(QhbApplication.class, args);
		QhbApplication.ServerStatus = 1;
		System.out.println("服务器启动完成");
	}
	
	public static boolean gameServerEnable(){
		return true;
	}

	public static boolean isStarted() {
		return ServerStatus == 1;
	}
	
	public static void destroy(){
		System.out.println("开始停止服务器");
		ServerStatus = 2;
		try {
			// 等待20s消耗已发的红包
			Thread.sleep(20*1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.exit(0);
		
	}
	
}
